import { formatMenu } from '../utils/index'
export const todoStateName = [
  { todoState: 0, name: '待处理' },
  { todoState: 1, name: '处理中' },
  { todoState: 2, name: '已处理' },
  { todoState: 3, name: '已取消' }
]

export const todotype = [
  { key: 0, name: '制表审批' },
  { key: 1, name: '表单填报' },
  { key: 2, name: '表单审核' }
]

export function doColumns(type) {
  return [
    {
      title: '序号',
      type: 'index',
      width: 60,
      align: 'center'
    },
    {
      title: '所属菜单',
      key: 'formMenu',
      align: 'center',
      render: (h, params) => {
        return h('Tooltip',
          {
            props: {
              transfer: true,
              maxWidth: '1000',
              content: formatMenu(this.menuList, params.row.formMenu),
              trigger: 'hover'
            }
          },
          [
            h('div', formatMenu(this.menuList, params.row.formMenu) || '-')
          ]
        )
      }
    },
    {
      title: '表单名称',
      key: 'formName',
      align: 'center',
    },
    {
      title: '当前填报周期',
      key: 'period',
      width: 100,
      align: 'center',
      render: (h, params) => { 
        return h('div', params.row.period || '-')
      }
    },
    {
      title: '任务名称',
      key: 'taskTitle',
      align: 'center',
    },
    {
      title: '当前节点',
      key: 'activityDefName',
      width: 130,
      align: 'center'
    },
    {
      title: '来自',
      width: 100,
      key: 'ownerName',
      align: 'center'
    },
    {
      title: '接收时间',
      key: 'beginTime',
      width: 150,
      align: 'center'
    },
    {
      title: '状态',
      width: 120,
      render: (h, params) => {
        return h('div', todoStateName.find(item => item.todoState == params.row.todoState)?.name)
      }
    },
    {
      title: '操作',
      align: 'left',
      fixed: 'right',
      width: 60,
      render: (h, params) => {
        return h('RowTools', {
          props: {
            data: [
              {
                type: 'text',
                text: type === 'todo' ? '处理' : '查阅',
                handle: () => {
                  this.goDetail(params.row)
                }
              }
            ]
          }
        })
      }
    }
  ]
}

export function toReadColumns() {
  return [
    {
      title: '序号',
      type: 'index',
      width: 60,
      align: 'center'
    },
    {
      title: '所属菜单',
      key: 'formMenu',
      render: (h, params) => {
        return h('div', formatMenu(this.menuList, params.row.formMenu) || '-')
      }
    },
    {
      title: '表单名称',
      key: 'formName'
    },
    {
      title: '当前填报周期',
      key: 'period',
      width: 100,
      align: 'center',
      render: (h, params) => { 
        return h('div', params.row.period || '-')
      }
    },
    {
      title: '任务名称',
      key: 'taskTitle',
      align: 'center',
    },
    {
      title: '当前节点',
      key: 'activityDefName',
      width: 130,
      align: 'center'
    },
    {
      title: '来自',
      width: 100,
      key: 'ownerName',
      align: 'center'
    },
    {
      title: '接收时间',
      key: 'beginTime',
      width: 150,
      align: 'center'
    },
    {
      title: '操作',
      align: 'left',
      fixed: 'right',
      width: 60,
      render: (h, params) => {
        return h('RowTools', {
          props: {
            data: [
              {
                type: 'text',
                text: '处理',
                handle: () => {
                  this.goDetail(params.row)
                }
              }
            ]
          }
        })
      }
    }
  ]
}

export function readColumns() {
  return [
    {
      title: '序号',
      type: 'index',
      width: 60,
      align: 'center'
    },
    {
      title: '所属菜单',
      key: 'formMenu',
      render: (h, params) => {
        return h('div', formatMenu(this.menuList, params.row.formMenu) || '-')
      }
    },
    {
      title: '表单名称',
      key: 'formName'
    },
    {
      title: '当前填报周期',
      key: 'period',
      width: 100,
      align: 'center',
      render: (h, params) => {
        return h('div', params.row.period || '-')
      }
    },
    {
      title: '任务名称',
      key: 'taskTitle',
      align: 'center',
    },
    {
      title: '当前节点',
      key: 'activityDefName',
      width: 130,
      align: 'center'
    },
    {
      title: '来自',
      width: 100,
      key: 'ownerName',
      align: 'center'
    },
    {
      title: '接收时间',
      key: 'beginTime',
      width: 150,
      align: 'center'
    },
    {
      title: '查阅时间',
      key: 'endTime',
      width: 150,
      align: 'center'
    },
    {
      title: '操作',
      align: 'left',
      fixed: 'right',
      width: 60,
      render: (h, params) => {
        return h('RowTools', {
          props: {
            data: [
              {
                type: 'text',
                text: '查阅',
                handle: () => {
                  this.goDetail(params.row)
                }
              }
            ]
          }
        })
      }
    }
  ]
}

export const periodList = [
  {
    value: '年度',
    label: '年度'
  },
  {
    value: '半年度',
    label: '半年度',
    children: [
      {
        value: '上半年',
        label: '上半年'
      },
      {
        value: '下半年',
        label: '下半年'
      }
    ]
  },
  {
    value: '季度',
    label: '季度',
    children: [
      {
        value: 'Q1',
        label: 'Q1'
      },
      {
        value: 'Q2',
        label: 'Q2'
      },
      {
        value: 'Q3',
        label: 'Q3'
      },
      {
        value: 'Q4',
        label: 'Q4'
      }
    ]
  },
  {
    value: '月度',
    label: '月度',
    children: [
      {
        value: '1月',
        label: '1月'
      },
      {
        value: '2月',
        label: '2月'
      },
      {
        value: '3月',
        label: '3月'
      },
      {
        value: '4月',
        label: '4月'
      },
      {
        value: '5月',
        label: '5月'
      },
      {
        value: '6月',
        label: '6月'
      },
      {
        value: '7月',
        label: '7月'
      },
      {
        value: '8月',
        label: '8月'
      },
      {
        value: '9月',
        label: '9月'
      },
      {
        value: '10月',
        label: '10月'
      },
      {
        value: '11月',
        label: '11月'
      },
      {
        value: '12月',
        label: '12月'
      }
    ]
  }
]
